package safe

import (
	"runtime/debug"

	logger "gitee.com/krio/ginc/example/core/lib/logger/zaplog"
)

// SafeGo 协程安全函数
func SafeGo(f func()) {
	defer func() {
		if err := recover(); err != nil {
			// 日志记录
			logger.Errorf("PANIC:%+v \\n %+v", err, debug.Stack())
		}
	}()

	f()
}
